#!/usr/bin/python

import sys
import bin2disascii

fr = open(sys.argv[1], "r")
orig_data = fr.read()
fr.close()


orig_data = orig_data.replace("\n", "")
orig_data = orig_data.replace("\r", "")
data = []
for i in range(0,len(orig_data),5):
    dec = bin2disascii.disascii2bin(orig_data[i:i+5])
    data += dec

actual_length = 0
for i in range(4):
    actual_length |= data[i]<<(i*8)

print "actual length : ", actual_length

result = ''.join([chr(i) for i in data[4:4+actual_length]])

f = open("result.tar.bz2", "wb")
f.write(result)
f.close()


